package cn.school.ajax;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.school.servies.StudentSerive;
import cn.school.tool.StringKit;

/**
 * Servlet implementation class StudentDelAjax
 */
@WebServlet("/StudentDelAjax")
public class StudentDelAjax extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public StudentDelAjax() {
		super();
		// TODO Auto-generated constructor stub
	}

	StudentSerive ss = new StudentSerive();

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		// response.getWriter().append("Served at: ").append(request.getContextPath());
		response.setContentType("application/json; charset=UTF-8");
		long stuno = StringKit.toLong(request.getParameter("stuno"));
		int a = ss.del1(stuno);
		String jg = null;
		System.out.println("结果是：" + a);
		if (a > 0) {
			jg = "{\"jieguo\":true}";
		} else {
			jg = "{\"jieguo\":false}";

		}
		response.getWriter().print(jg);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
